package com.example.demo.entity.primary;

import javax.persistence.*;

/**
 * Created by dongjunpeng on 2017/10/12.
 */
@Entity
@Table(name = "camera_preset")
public class CameraPresetEntity {
    private int cameraPresetId;
    private Byte presetNumber;
    private String presetName;
    private CameraEntity cameraByCameraId;

    @Id
    @Column(name = "camera_preset_id")
    public int getCameraPresetId() {
        return cameraPresetId;
    }

    public void setCameraPresetId(int cameraPresetId) {
        this.cameraPresetId = cameraPresetId;
    }

    @Basic
    @Column(name = "preset_number")
    public Byte getPresetNumber() {
        return presetNumber;
    }

    public void setPresetNumber(Byte presetNumber) {
        this.presetNumber = presetNumber;
    }

    @Basic
    @Column(name = "preset_name")
    public String getPresetName() {
        return presetName;
    }

    public void setPresetName(String presetName) {
        this.presetName = presetName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CameraPresetEntity that = (CameraPresetEntity) o;

        if (cameraPresetId != that.cameraPresetId) return false;
        if (presetNumber != null ? !presetNumber.equals(that.presetNumber) : that.presetNumber != null) return false;
        if (presetName != null ? !presetName.equals(that.presetName) : that.presetName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = cameraPresetId;
        result = 31 * result + (presetNumber != null ? presetNumber.hashCode() : 0);
        result = 31 * result + (presetName != null ? presetName.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "camera_id", referencedColumnName = "camera_id", nullable = false)
    public CameraEntity getCameraByCameraId() {
        return cameraByCameraId;
    }

    public void setCameraByCameraId(CameraEntity cameraByCameraId) {
        this.cameraByCameraId = cameraByCameraId;
    }

}
